package io.bitmax.exchange.login.entity;

import android.os.Parcel;
import android.os.Parcelable;

import org.json.JSONObject;

/**
 * 用戶信息
 * Created by gongdongyang on 2018/9/25.
 */

public class User implements Parcelable{

    private String account;
    private String phone;
    private String type;
    private String state;
    private String token;
    private String head;
    private String uuid;
    private JSONObject portrait;


    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.account);
        dest.writeString(this.phone);
        dest.writeString(this.type);
        dest.writeString(this.state);
        dest.writeString(this.token);
        dest.writeString(this.head);
        dest.writeString(this.uuid);
        //dest.writeParcelable(this.portrait, flags);
        dest.writeString(this.portrait.toString());
    }

    public User() {
        //portrait = new JSONObject();
    }

    protected User(Parcel in) {
        this.account = in.readString();
        this.phone = in.readString();
        this.type = in.readString();
        this.state = in.readString();
        this.token = in.readString();
        this.head = in.readString();
        this.uuid = in.readString();
        try{
            this.portrait = new JSONObject(in.readString());
        }catch ( Exception e){

        }
        //this.portrait = in.readParcelable(JSONObject.class.getClassLoader());
    }

    public static final Creator<User> CREATOR = new Creator<User>() {
        @Override
        public User createFromParcel(Parcel source) {
            return new User(source);
        }

        @Override
        public User[] newArray(int size) {
            return new User[size];
        }
    };
}
